vector->list, list->vector - conversion between vectors and lists

LIBRARY

(import (rnrs))                     ;R6RS
(import (rnrs base))                ;R6RS
(import (scheme r5rs))              ;R7RS
(import (scheme base))              ;R7RS

SYNOPSIS

(vector->list vector)
(vector->list vector start)         ;R7RS
(vector->list vector start end)     ;R7RS
(list->vector list)

DESCRIPTION

The vector->list procedure returns a newly allocated list of the objects contained in the elements of vector.

The list->vector procedure returns a newly created vector initialized to the elements of the list list.

In both procedures, order is preserved.

R7RS
The vector->list procedure is limited to the elements between start (inclusive) and end (exclusive). These arguments default to 0 and the length of the vector, respectively.

IMPLEMENTATION NOTES

Chez Scheme, Loko Scheme
The empty vector is a unique object, so (list->vector '()) does not return a newly allocated vector.

RETURN VALUES

These procedures both return a single value; a vector object or a list.

EXAMPLES

(vector->list '#(dah dah didah))
            => (dah dah didah)

(list->vector '(dididit dah))
            => #(dididit dah)

COMPATIBILITY

These procedures work the same everywhere except for the start and end arguments, which are only present in the R7RS variant of vector->list.

ERRORS

This procedure can raise exceptions with the following condition types:
&assertion (R6RS)
The wrong number of arguments was passed or an argument was outside its domain.
R7RS
The assertions described above are errors. Implementations may signal an error, extend the procedure's domain of definition to include such arguments, or fail catastrophically.

In particular, if list->vector is passed a cyclical list then the procedure may not terminate.

SEE ALSO

vector(3scm), list(3scm), list->string(3scm), vector->string(3scm)

STANDARDS

R4RS, R5RS, R6RS, R7RS

HISTORY

These procedures first appeared in R2RS. They were left out of IEEE Scheme. But in spite of this, list->vector appears as an example in the standard.

AUTHORS

This page is part of the scheme-manpages project. It includes materials from the RnRS documents. More information can be found at https://github.com/schemedoc/manpages/.


Markup created by unroff 1.0sc,    March 04, 2023.